<?php
/**
 * @version:		$Id: index.php 8 2011-08-02 23:17:34Z epatarroyo $
 * @copyright:		Copyright (C) 2010 OpenWeb Software. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
* @TODO Crear imagenes template_preview.png y template_thumbnail.png
*/

defined('_JEXEC') or die;

/* The following line loads the MooTools JavaScript Library */
JHtml::_('behavior.framework', true);

/* The following line gets the application object for things like displaying the site name */
$app        = JFactory::getApplication();
$doc        = JFactory::getDocument();
$user       = JFactory::getUser();
$status     = $user->guest;

/* get params */
$templateparams   = $app->getTemplate(true)->params;

include (dirname(__FILE__).DS.'/tools/tools.php');

if((!$detect->isTablet() && $detect->isMobile() && $mobileTemplate) || (isset($_GET['mobile']) && $_GET['mobile'] == "ok" && $mobileTemplate) ){
 include (dirname(__FILE__).DS.'index.mobile.php');
}else{
  $doc->addStyleSheet($this->baseurl.'/templates/'.$this->template.'/css/template.min.css', $type = 'text/css', $media = 'screen,projection');
  if(file_exists($_SERVER['DOCUMENT_ROOT'] . $cssBrowser)){
    $doc->addStyleSheet($cssBrowser, $type = 'text/css', $media = 'screen,projection');
  }
  $doc->addStyleSheet($this->baseurl.'/templates/'.$this->template.'/css/print.css', $type = 'text/css', $media = 'print');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
<head>
<jdoc:include type="head" />
<?php  ?>
<?php echo $dynamicstyles; ?>
<?php if($googleAnalitycs != ""){ ?>
  <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '<?php echo $googleAnalitycs; ?>']);
    _gaq.push(['_trackPageview']);
    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
  </script>
<?php } ?>
</head>

<body>
<div class="accessibility">
  <ul>
    <li><a href="#mainmenu"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_NAV'); ?></a></li>
    <?php if ($this->countModules( 'nav2' )) : ?>
    <li><a href="#aside"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_NAV2'); ?></a></li>
    <?php endif; ?>
    <li><a href="#content"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_CONTENT'); ?></a></li>
    <li><a href="#footer"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_FOOTER'); ?></a></li>
  </ul>
</div>

<?php if ($this->countModules('usermenu')) : ?>
<div id="usermenu">
  <div class="wrapper">
    <div class="nav">
      <jdoc:include type="modules" name="usermenu" style="none" />
    </div>
  </div>
</div>
<?php endif; ?>

<div id="wrapper">
  <?php if(!$editMode){ ?>
  <div id="header">
    <div class="wrapper">
      <div id="logo"><a href="<?php echo $this->baseurl ?>"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/images/logo.png" alt="<?php echo JText::_('TPL_OW-BYTE_LOGO_ALT'); ?>" /></a></div>
      <?php if ($this->countModules('tagline')) : ?>
      <div id="tagline"><jdoc:include type="modules" name="tagline" style="none" /></div>
      <?php endif; ?>
      
      <?php if ($this->countModules('lang') && $status == 1) : ?>
      <div id="lang"><jdoc:include type="modules" name="lang" style="none" /></div>
      <?php elseif ($status == 0) : ?>
      <div id="logout"><jdoc:include type="modules" name="logout" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('search')) : ?>
      <div id="search"><jdoc:include type="modules" name="search" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('nav06')) : ?>
      <div id="nav06" class="nav"><jdoc:include type="modules" name="nav06" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('header1')) : ?>
      <div id="header1"><jdoc:include type="modules" name="header1" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('header2')) : ?>
      <div id="header2"><jdoc:include type="modules" name="header2" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('header3')) : ?>
      <div id="header3"><jdoc:include type="modules" name="header3" style="none" /></div>
      <?php endif; ?>
    </div>
  </div>
  <?php } ?>

  <?php if (!$editMode && $this->countModules('nav01')) : ?>
  <div id="mainmenu" class="nav">
    <div class="wrapper">
    <?php if($status == 1){ ?>
      <jdoc:include type="modules" name="nav01" style="none" />
    <?php } else { ?>
      <jdoc:include type="modules" name="nav-intranet" style="none" />
    <?php } ?>
    </div>
  </div>
  <?php endif; ?>

  <?php if (!$searchResults && !$editMode && $this->countModules( 'call2action' )) : ?>
  <div id="call2action">
    <div class="wrapper"><jdoc:include type="modules" name="call2action" style="none" /></div>
  </div>
  <?php endif; ?>

  <?php
  if (
  !$searchResults && !$editMode && (
  $this->countModules('featured1A') ||
  $this->countModules('featured1B') ||
  $this->countModules('featured1C') ||
  $this->countModules('featured2A') ||
  $this->countModules('featured2B') ||
  $this->countModules('featured2C') ||
  $this->countModules('featured3A') ||
  $this->countModules('featured3B') ||
  $this->countModules('featured3C')
  )) {
  ?>
  <div id="featured">
    <div class="wrapper">
      <?php if ( $this->countModules('featured1A') || $this->countModules('featured1B') || $this->countModules('featured1C') ) { ?>
      <div id="featured1">        
        
        <?php if ($this->countModules('featured1A')) : ?>
        <div id="featured1A">
          <jdoc:include type="modules" name="featured1A" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>

        <?php if ($this->countModules('featured1B')) : ?>
        <div id="featured1B">
          <jdoc:include type="modules" name="featured1B" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>

        <?php if ($this->countModules('featured1C')) : ?>
        <div id="featured1C">
          <jdoc:include type="modules" name="featured1C" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <div class="clr"></div>
      </div>
      <?php } ?>

      <?php if ( $this->countModules('featured2A') || $this->countModules('featured2B') || $this->countModules('featured2C') ) { ?>
      <div id="featured2">
        
        <?php if ($this->countModules('featured2A')) : ?>
        <div id="featured2A">
          <jdoc:include type="modules" name="featured2A" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>

        <?php if ($this->countModules('featured2B')) : ?>
        <div id="featured2B">
          <jdoc:include type="modules" name="featured2B" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>

        <?php if ($this->countModules('featured2C')) : ?>
        <div id="featured2C">
          <jdoc:include type="modules" name="featured2C" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <div class="clr"></div>
      </div>
      <?php } ?>

      <?php if ( $this->countModules('featured3A') || $this->countModules('featured3B') || $this->countModules('featured3C') ) { ?>
      <div id="featured3">

        <?php if ($this->countModules('featured3A')) : ?>
        <div id="featured3A">
          <jdoc:include type="modules" name="featured3A" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>

        <?php if ($this->countModules('featured3B')) : ?>
        <div id="featured3B">
          <jdoc:include type="modules" name="featured3B" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>

        <?php if ($this->countModules('featured3C')) : ?>
        <div id="featured3C">
          <jdoc:include type="modules" name="featured3C" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <div class="clr"></div>
      </div>
      <?php } ?>

    </div>
  </div>
  <?php } ?>

  <div id="main">
    <div class="wrapper">
      <?php if (!$editMode && $this->countModules( 'breadcrumbs' )) : ?>
      <div id="breadcrumbs"><jdoc:include type="modules" name="breadcrumbs" style="none" /></div>
      <?php endif; ?>

      <?php if (!$searchResults && !$editMode && ($this->countModules( 'col1Top' ) || $this->countModules( 'nav02' ) || $this->countModules( 'col1Bottom' ))) : ?>
      <div id="col1">
        <div class="aside">
          <div class="padding">
            <?php if ($this->countModules( 'col1Top' )) : ?>
            <jdoc:include type="modules" name="col1Top" style="xhtml1" headerLevel="4" />
            <?php endif; ?>
            <?php if ($this->countModules( 'nav02' )) : ?>
            <div class="nav"><jdoc:include type="modules" name="nav02" style="xhtml0" /></div>
            <?php endif; ?>
            <?php if ($this->countModules( 'col1Bottom' )) : ?>
            <jdoc:include type="modules" name="col1Bottom" style="xhtml1" headerLevel="4" />
            <?php endif; ?>
          </div>
        </div>
      </div>
      <?php endif; ?>

      <div id="content">
        <div class="padding">
          <?php if (!$searchResults && !$editMode && $this->countModules( 'nav03' )) : ?>
          <div class="nav"><jdoc:include type="modules" name="nav03" style="none" /></div>
          <?php endif; ?>
          <?php if (!$searchResults && !$editMode && $this->countModules( 'top' )) : ?>
          <div class="top"><jdoc:include type="modules" name="top" style="xhtml1" headerLevel="4" /></div>
          <?php endif; ?>
          <div id="message"><jdoc:include type="message" /></div>
          <div id="component"><jdoc:include type="component" /></div>
          <div class="accessibility">
            <ul>
              <li><a href="#mainmenu"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_NAV'); ?></a></li>
            </ul>
          </div>
          <?php if (!$editMode && $this->countModules( 'extras' )) : ?>
          <div id="extras"><jdoc:include type="modules" name="extras" style="xhtml1" headerLevel="4" /></div>
          <?php endif; ?>
        </div>
      </div>

      <?php if (!$searchResults && !$editMode && ($this->countModules( 'col2Top' ) || $this->countModules( 'nav04' ) || $this->countModules( 'col2Bottom' ))) : ?>
      <div id="col2">
        <div class="aside">
          <div class="padding">
            <?php if ($this->countModules( 'col2Top' )) : ?>
            <jdoc:include type="modules" name="col2Top" style="xhtml1" headerLevel="4" />
            <?php endif; ?>
            <?php if ($this->countModules( 'nav04' )) : ?>
            <div class="nav"><jdoc:include type="modules" name="nav04" style="none" /></div>
            <?php endif; ?>
            <?php if ($this->countModules( 'col2Bottom' )) : ?>
            <jdoc:include type="modules" name="col2Bottom" style="xhtml1" headerLevel="4" />
            <?php endif; ?>
          </div>
        </div>
      </div>
      <?php endif; ?>

      <?php if (!$editMode && $this->countModules( 'bottom' )) : ?>
      <div id="bottom"><jdoc:include type="modules" name="bottom" style="xhtml1" /></div>
      <?php endif; ?>

    </div>
    <div class="clr"></div>
  </div>

  <?php if(!$editMode){ ?>
  <div id="footer">
    <div class="wrapper">
      <div class="padding">
        <?php if ($this->countModules( 'footer1' )) : ?>
        <div id="footer1"><jdoc:include type="modules" name="footer1" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>

        <?php if ($this->countModules( 'footer2' )) : ?>
        <div id="footer2"><jdoc:include type="modules" name="footer2" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>

        <?php if ($this->countModules( 'nav05' ) && $status == 1) : ?>
        <div class="nav c<?php echo $this->countModules( 'nav05' ) ?>"><jdoc:include type="modules" name="nav05" style="xhtml2" headerLevel="5" /></div>
        <?php endif; ?>

        <?php if ($this->countModules( 'socialMedia' )) : ?>
        <div id="socialMedia"><jdoc:include type="modules" name="socialMedia" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>

        <?php if ($this->countModules( 'about' )) : ?>
        <div id="about"><jdoc:include type="modules" name="about" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>

        <?php if ($this->countModules( 'copyright' )) : ?>
        <div id="copyright"><jdoc:include type="modules" name="copyright" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>

        <?php if ($this->countModules( 'footer3' )) : ?>
        <div id="footer3"><jdoc:include type="modules" name="footer3" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>
        
        <?php if ($this->countModules( 'footer4' )) : ?>
        <div id="footer4"><jdoc:include type="modules" name="footer4" style="xhtml1" headerLevel="5" /></div>
        <?php endif; ?>
      </div>
    </div>
  </div>
  <?php } ?>

</div>

<div class="accessibility">
  <ul>
    <li><a href="#mainmenu"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_NAV'); ?></a></li>
    <li><a href="#content"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_CONTENT'); ?></a></li>
    <li><a href="#header"><?php echo JText::_('TPL_OW-BYTE_JUMP_TO_TOP'); ?></a></li>
  </ul>
</div>

<?php
if($debugMode){
  include (dirname(__FILE__).DS.'/tools/debug.php');
}
?>
</body>
</html>
<?php } ?>